package com.panopset.gui;

import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * Integer properties file value editor.
 * 
 * @author Karl Dinwiddie
 * 
 */
public class PropvalEditorBigDecimal extends PropvalEditor {

	/**
	 * @return BigDecimal value.
	 * @throws Exception Exception.
	 */
	public BigDecimal getBigDecimal() throws Exception {
		return getBD(getValue());
	}

	private BigDecimal getBD(final String s) throws Exception {
		return new BigDecimal(s);
	}

	/**
	 * @param propertiesFileName
	 *            Properties file name.
	 */
	public PropvalEditorBigDecimal(final String propertiesFileName) {
		this(null, propertiesFileName);
	}

	/**
	 * @param defaultResourcePath
	 *            Default resource path.
	 * @param propertiesFileName
	 *            Properties file name.
	 */
	public PropvalEditorBigDecimal(final String defaultResourcePath,
			final String propertiesFileName) {
		super(defaultResourcePath, propertiesFileName);
	}

	@Override
	protected final boolean validate(final String s) {
		try {
			String compare = "" + getBD(s);
			return (compare).equals(s);
		} catch(Exception ex) {
			return false;
		}
	}

}
